<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title><?php echo $title;?></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../public/plugin/layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header" style="padding-top:30px;"><?php echo $title;?></div>
          <div class="layui-card-body" pad15>
            <div class="layui-form">
              <div class="layui-form-item">
                <label class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="oldPassword" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="password" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="repassword" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" id="updata">确认修改</button>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
  </div> 
</body>
</html>
<script src="../../public/js/jquery.js"></script>
<script src="../../public/plugin/layer/layer.js"></script>
<script>
	$(function(){
		$("#updata").click(function(){
			var oldPassword = $("input[name='oldPassword']").val();
			var password = $("input[name='password']").val();
			var repassword = $("input[name='repassword']").val();
			var name = '<?php echo $_SESSION['userInfo']['name'];?>';
			if(oldPassword == '' || password == '' || repassword == ''){
				layer.alert('不能为空！');
				return false;
			}
			if(password.length<4 || password.length > 16){
				layer.alert('密码不符合规范！');
				return false;
			}
			if(password != repassword){
				layer.alert('两次密码不一致！');
				return false;
			}
			if(oldPassword == password){
				layer.alert('新旧密码不能一样！');
				return false;
			}
			$.ajax({
				type:"POST",
				data:{"name":name,"password":password},
				url:'ajaxPassword.php',
				success:function(data){
					layer.alert(data);
				}
			});
		});
	});
</script>